package com.yygo.jobs;

import com.yygo.model.LoanRequest;
import com.yygo.service.LoanPersonManager;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.ArrayList;
import java.util.List;
import java.util.Set;

/**
 * Created by tiansha on 2015/7/8.
 */
public abstract class BaseRuleProcessor {

    @Autowired
    private LoanPersonManager loanPersonManager;

    protected List<LoanRequest> getHistoryRequests(LoanRequest loanRequest) {
        List<LoanRequest> list = loanPersonManager.findByIdNo(loanRequest);
        return list;
    }

    protected List<LoanRequest> getMobileRequests(LoanRequest loanRequest) {
        List<LoanRequest> list = loanPersonManager.findByProperty(loanRequest, "mobileNo", 60);
        return list;
    }

    protected List<LoanRequest> getHomeTelRequests(LoanRequest loanRequest) {
        List<LoanRequest> list = loanPersonManager.findByProperty(loanRequest, "homeTelNo", 60);
        return list;
    }

    protected List<LoanRequest> getWorkTelRequests(LoanRequest loanRequest) {
        List<LoanRequest> list = loanPersonManager.findByProperty(loanRequest, "workTelNo", 60);
        return list;
    }

    protected List<LoanRequest> getWorkCompanyRequests(LoanRequest loanRequest) {
        List<LoanRequest> list = loanPersonManager.findByProperty(loanRequest, "workCompany", 60);
        return list;
    }

    protected List<LoanRequest> getAddressRequests(LoanRequest loanRequest) {
        List<LoanRequest> list = loanPersonManager.findByAddress(loanRequest, 60);
        return list;
    }

    protected List<LoanRequest> getCompanyAddressRequests(LoanRequest loanRequest) {
        List<LoanRequest> list = loanPersonManager.findByCompanyAddress(loanRequest, 60);
        return list;
    }

    protected List<LoanRequest> getUrgentNoRequests(LoanRequest loanRequest) {
        List<LoanRequest> list = loanPersonManager.findByUrgentNo(loanRequest, 60);
        return list;
    }

    protected List<LoanRequest> getIdentityAddressRequests(LoanRequest loanRequest) {
        List<LoanRequest> list = loanPersonManager.findByIdentity(loanRequest, 30);
        return list;
    }

    protected List<String> getNumbers(List<LoanRequest> list) {
        List<String> numbers = new ArrayList<>();
        for (LoanRequest request : list) {
            numbers.add(request.getNumber());
        }
        return numbers;
    }
}
